package com.kavin.user.feign.order;

import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component //注入Spring 容器中
public class OrderHystrixClientFactory implements FallbackFactory<OrderInterface> {
    private static final Logger logger = LoggerFactory.getLogger(OrderHystrixClientFactory.class);

    @Override
    public OrderInterface create(Throwable cause) {
        //一进入异常就能知道什么异常
        OrderHystrixClientFactory.logger.info("fallback; exception was: {}", cause.toString());
        OrderHystrixClientFactory.logger.info("fallback; reason was: {}", cause.getMessage());
       return () -> "系统异常";
    }
}